<?php
/**
 * LoginTextDao.class.php
 * 
 * (C) 2009, tetsuya.odaka(EzoGP).
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* 
 * users.txtのためのDao
 * 
 * 		author	；	t.odaka
 * 		date	;	2009/5/7
 * 
 * 		update	;	t.odaka users.txtへのRoleの追加による
 * 
 */
require_once('BaseTextDao.class.php');

class LoginTextDao extends BaseTextDao {
	/*
	* プロパティー 
	*/
	var $Email, $Password, $Role;

    /* 
	 * デフォルトのコンストラクタ 
	 */
	function __construct() {
		parent::__construct();
	}

	/* 
	 * Getter 
	 */
	function getEmail(){return $this->Email;}
	function getPassword(){return $this->Password;}
	function getRole(){return $this->Role;}
	
	/* 
	 * Setter 
	 */
	function setEmail($_str){$this->Email = $_str;}
	function setPassword($_str){$this->Password = $_str;}
	function setRole($_str){$this->Role = $_str;}
	
	/*
 	* findByUniqueKey
 	*   主キーをもとに、データを取得する。
	*   パラメータ
	*   $_fp	:	this->FileNameのファイルポインタ
 	*  	戻り値	:	見つかったらLoginTextDaoオブジェクト、なかったらnull.
 	*/
	function findByUniqueKey($_fp, $_key){
		require("../Myznala/debugLog.php");
//		$myDebugLog->debug('$_key: '.$_key); // Debugログ
		
		while($_rarray = fgetcsv($_fp,1024,',')){
//			$myDebugLog->debug('$_rarray[0]: '.$_rarray[0]); // Debugログ
			if($_rarray[0] == $_key){
				$_retObj = new LoginTextDao();
				$_retObj->setEmail($_rarray[0]);
				$_retObj->setPassword($_rarray[1]);
				$_retObj->setRole($_rarray[2]);
				return $_retObj;
			}
		}
		return null;
	}
}
?>